﻿/*********************************************************************************
 *Author:         OnClick
 *Version:        1.0
 *UnityVersion:   2018.3.1f1
 *Date:           2019-03-26
 *Description:    IFramework
 *History:        2018.11--
*********************************************************************************/
using System;

namespace IFramework
{
    public class AcceptInfo : BaseInfo
    {
        public string SecWebSocketAccept { get; set; }// 接入访问验证码
        public string SecWebSocketLocation { get; set; }// 客户端来源
        public string SecWebSocketOrigin { get; set; }// 服务端来源
        public bool IsHandShaked { get { return !string.IsNullOrEmpty(SecWebSocketAccept); } }
        public override string ToString()
        {
            if (string.IsNullOrEmpty(HttpProto))
                HttpProto = "HTTP/1.1 101 Switching Protocols";
            return string.Format("{0}{1}{2}{3}", HttpProto + Environment.NewLine,
                "Connection: " + Connection + Environment.NewLine, "Upgrade: " + Upgrade + Environment.NewLine,
                 "Sec-WebSocket-Accept: " + SecWebSocketAccept + Environment.NewLine + Environment.NewLine//很重要，需要两个newline
                );
        }
    }

}
